// 统一封装接口方法、
// 每个方法负责请求一个url地址
// 逻辑页面，导入这个接口方法，就能发请求
// 好处：请求url路径，可以在这里统一管理
import axios from '@/utils/request.js'
import { getToken } from '@/utils/token.js'
// 登录
export const loginAPI = ({ mobile, code }) => axios({
  url: '/v1_0/authorizations',
  method: 'POST',
  data: { mobile, code }
})

// 获取所有频道
export const getAllChannelsAPI = () => axios({
  url: '/v1_0/channels',
  method: 'GET'

})
// 获取用户频道
export const getUserChannelsAPI = () => axios({
  url: '/v1_0/user/channels',
  headers: {
    Authorization: `Bearer + ${getToken()}`
  }
})
// 更改频道
export const updateUserChannelAPI = (channels) => axios({
  url: '/v1_0/user/channels',
  method: 'PUT',
  headers: {
    Authorization: `Bearer + ${getToken()}`
  },
  data: {
    channels
  }
})

// 删除频道
export const deleteUserChannelAPI = ({ channelsId }) => axios({
  url: `/v1_0/user/channels/${channelsId}`,
  method: 'DELETE',
  headers: {
    Authorization: `Bearer + ${getToken()}`
  }
})
// 获取文章列表

export const getAllArticleListAPI = ({ channel_id, timestamp }) => axios({
  url: '/v1_0/articles',
  headers: {
    Authorization: `Bearer + ${getToken()}`
  },
  params: {
    channel_id,
    timestamp
  }
})

// 用户反馈
export const feedbackAPI = ({ ardId }) => axios({
  url: '/v1_0/article/dislikes',
  method: 'POST',
  headers: {
    Authorization: `Bearer ${getToken()}`
  },
  data: { target: ardId }
})

// 举报文章

export const reportAPI = ({ ardId, typeId, remarkSm }) => axios({
  url: '/v1_0/article/reports',
  method: 'POST',
  headers: {
    Authorization: `Bearer ${getToken()}`
  },
  data: {
    target: ardId,
    type: typeId,
    remark: remarkSm
  }

})

// 搜索联想建议
export const suggestListAPI = ({ search }) => axios({
  url: '/v1_0/suggestion',
  headers: {
    Authorization: `Bearer ${getToken()}`
  },
  params: {
    q: search
  }
})
